package clickhouse

import (
	"gitee.com/csingo/cDB/drivers"
)

const (
	Driver drivers.DBDriver = "clickhouse"
)

type Connection struct {
	Driver      drivers.DBDriver `json:"driver"`
	Host        string           `json:"host"`
	Port        int              `json:"port"`
	Database    string           `json:"database"`
	Username    string           `json:"username"`
	Password    string           `json:"password"`
	ReadTimeout int64            `json:"read_timeout"`
	DialTimeout int64            `json:"dial_timeout"`
	Debug       bool             `json:"debug"`
	Pool        *ConnectionPool  `json:"pool"`
}

type ConnectionPool struct {
	MaxIdleConnections int `json:"max_idle_connections"`
	MaxConnections     int `json:"max_connections"`
	ConnectTimeout     int `json:"connect_timeout"`
	MaxIdleTime        int `json:"max_idle_time"`
}

func (i *Connection) GetDriver() drivers.DBDriver {
	return i.Driver
}

func (i *Connection) IsDebug() bool {
	return i.Debug
}

func (i *Connection) NewConnector(name string) (drivers.ConnectorInterface, error) {
	return NewClickhouseConnector(name, i)
}
